import { createParamDecorator, ExecutionContext } from '@nestjs/common';

export const UserDec = createParamDecorator(
  (prop: string | null = null, ctx: ExecutionContext): any => {
    const request = ctx.switchToHttp().getRequest();

    const user = request.user;

    return prop ? user?.[prop] : user;
  },
);
